/*
 * Copyright 2007 National Bioinformatics Network
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dgbgui.command;

import dgbgui.gui.widgets.visual.QueryWidgetState;
import dgbgui.modeldocument.ModelDocument;
import dgbgui.modeldocument.Query;

public class ReplaceQueryCommand implements Command {

    public ReplaceQueryCommand(Query from, Query to) {
        m_fromNode = from;
        m_toNode = to;
    }
    
    public void execute() {
        // FIXME: 
        //m_widgetState = WidgetStore.getInstance().getWidget(m_fromNode).getWidgetStateCopy();
        ModelDocument.getInstance().replace(m_fromNode,m_toNode);
        //DefaultCanvasScene.getInstance().getQueryWidget(m_toNode).setState(m_widgetState);
    }


    public void undo() {
        ModelDocument.getInstance().replace(m_toNode,m_fromNode);  
        //DefaultCanvasScene.getInstance().getQueryWidget(m_fromNode).setState(m_widgetState);

    }
    
    public void redo() {
        ModelDocument.getInstance().replace(m_fromNode,m_toNode);
        //DefaultCanvasScene.getInstance().getQueryWidget(m_toNode).setState(m_widgetState);
    }
    
    public boolean isUndoable() {
        return true;
    }

    QueryWidgetState m_widgetState;
    Query m_fromNode,m_toNode;

}
